import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 设备分类信息 */
export interface EquipmentType {
  id: number // 分类id
  name?: string // 分类名称
  description?: string // 描述
}

// 设备分类 API
export const EquipmentTypeApi = {
  // 查询设备分类分页
  getEquipmentTypePage: async (params: any) => {
    return await request.get({ url: `/business/equipment-type/page`, params })
  },

  // 查询设备分类分页
  getEquipmentTypePageDamage: async (params: any) => {
    return await request.get({ url: `/Damage/equipment-keep-config/damagePage`, params })
  },

  // 查询设备分类详情
  getEquipmentType: async (id: number) => {
    return await request.get({ url: `/business/equipment-type/get?id=` + id })
  },

  // 查询所有设备分类
  getEquipmentTypeList: async () => {
    return await request.get({ url: `/business/equipment-type/getAllList` })
  },

  // 新增设备分类
  createEquipmentType: async (data: EquipmentType) => {
    return await request.post({ url: `/business/equipment-type/create`, data })
  },

  // 修改设备分类
  updateEquipmentType: async (data: EquipmentType) => {
    return await request.put({ url: `/business/equipment-type/update`, data })
  },

  // 删除设备分类
  deleteEquipmentType: async (id: number) => {
    return await request.delete({ url: `/business/equipment-type/delete?id=` + id })
  },

  /** 批量删除设备分类 */
  deleteEquipmentTypeList: async (ids: number[]) => {
    return await request.delete({
      url: `/business/equipment-type/delete-list?ids=${ids.join(',')}`
    })
  },

  // 导出设备分类 Excel
  exportEquipmentType: async (params) => {
    return await request.download({ url: `/business/equipment-type/export-excel`, params })
  },

  // 下载导入模板
  importTemplate: async () => {
    return request.download({ url: '/business/equipment-type/get-import-template' })
  }
}
